import {PreloadingStrategy, Route} from '@angular/router';
import {Observable} from 'rxjs/Observable';

export class SelectivePreloadingStrategy implements PreloadingStrategy {
  preloadedModules: string[] = [];

  preload(route: Route, load: () => Observable<any>): Observable<any> {
    //提前加载哪个模块，navigation-routing中配置，data: { preload: true }
    if (route.data && route.data['preload']) {
      // add the route path to the preloaded module array
      this.preloadedModules.push(route.path);
      return load();
    } else {
      return Observable.of(null);
    }
  }
}


// WEBPACK FOOTER //
// ./src/app/selective-preloading-strategy.ts
